package com.gitee.feizns.quickstart.spring.data.jpa.autoconfigure;

import org.hibernate.jpa.boot.spi.IntegratorProvider;
import org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesCustomizer;

import java.util.Collections;
import java.util.Map;

/**
 * @link <a href="https://juejin.cn/post/6913166066550063118">使用JPA自动建表时优雅的添加注释</a>
 * @author feizns
 * @since 2022/11/9
 */
public class TableCommentHibernatePropertiesCustomizer implements HibernatePropertiesCustomizer {

    @Override
    public void customize(Map<String, Object> hibernateProperties) {
        hibernateProperties.put("hibernate.use_sql_comments", true);
        hibernateProperties.put("hibernate.integrator_provider",
                (IntegratorProvider) () -> Collections.singletonList(CommentIntegrator.INSTANCE));
    }

}
